export default {
	data() {
		return {
		}
	},
	onLoad: function() {
		uni.showShareMenu({
			withShareTicket: true,
			menus: ["shareAppMessage", "shareTimeline"]
		})
	},
	// 分享给个人
	onShareAppMessage(res) {
		let that = this;
		let imageUrl = that.shareUrl || '';

		const openId = uni.getStorageSync("openId")
		let data = JSON.stringify({
			inviteOpenId: openId
		})
		if (res.from === 'button') {
			//这块需要传参，不然链接地址进去获取不到数据
			let path = `/` + that.$scope.route + `?item=` + that.$scope.options.item;
			return {
				title: '分享标题随便填啦',
				path: '/pages/index/index?data=' + encodeURIComponent(data),  // 固定打开index首页
				path: path, // 打开分享的指定页面
				// imageUrl: '/static/share.jpg'
			};
		}
		if (res.from === 'menu') {
			return {
				title: '分享标题随便填啦',
				path: '/pages/index/index?data=' + encodeURIComponent(data),
				imageUrl: imageUrl,
			};
		}
	},
	// 分享到朋友圈
	onShareTimeline() {
		return {
			title: 'magicTang',
			path: '/pages/index/index',
			imageUrl: '/static/share.jpg'
		};
	}
}